package ar.com.tesis.mobile.aplicacion;

import android.graphics.Bitmap;

import com.nostra13.universalimageloader.cache.memory.impl.LRULimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.orm.SugarApp;

public class TesisApp extends SugarApp {

    @Override
    public void onCreate() {

        super.onCreate();
        configureUniversalImageLoader();
    }

    private void configureUniversalImageLoader() {

        DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .resetViewBeforeLoading(false)
                .bitmapConfig(Bitmap.Config.ALPHA_8)
                .imageScaleType(ImageScaleType.EXACTLY)
                .build();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
                .threadPoolSize(3)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache((new LRULimitedMemoryCache((int) (Runtime.getRuntime().maxMemory() / 1024) / 3)))
                .threadPriority(Thread.MIN_PRIORITY + 3)
                .defaultDisplayImageOptions(defaultOptions)
                .build();
        ImageLoader.getInstance().init(config);
    }
}
